package com.xuxin.baby.activity;

import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.uuzuche.lib_zxing.activity.CodeUtils;
import com.xuxin.baby.R;
import com.xuxin.baby.base.BaseActivity;
import com.xuxin.baby.base.BaseConstant;
import com.xuxin.baby.bean.BaseBean;
import com.xuxin.baby.contract.UserCodeContract;
import com.xuxin.baby.presenter.UserCodePresenter;
import com.xuxin.baby.utils.ACache;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by xu_xin
 * Created on 2020.08.05 0005
 * 邀请码
 */
public class UserCodeActivity extends BaseActivity implements UserCodeContract.View {
    private final UserCodeContract.Presenter presenter = new UserCodePresenter(this);
    @BindView(R.id.title_left)
    ImageView title_left;
    @BindView(R.id.title_right)
    ImageView title_right;
    @BindView(R.id.title_name)
    TextView title_name;
    @BindView(R.id.activity_user_code_QR)
    ImageView activity_user_code_QR;


    @Override
    public void setContentView() {
        setContentView(R.layout.activity_user_code);
    }

    @Override
    public void initView() {
        title_name.setText("邀请码");
    }

    @Override
    public void initData() {
        ACache aCache = ACache.get(this);
        String memberId = aCache.getAsString(BaseConstant.memberId);
        Bitmap qrImage = CodeUtils.createImage("id=" + memberId, 360, 360, null);
        activity_user_code_QR.setImageBitmap(qrImage);
    }

    @Override
    public void onComplete() {

    }

    @Override
    @OnClick({R.id.title_left})
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.title_left) {
            finish();
        }
    }

    private final Handler handler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(@NonNull Message msg) {
            switch (msg.what) {
                case 0:
                    break;
            }
            return false;
        }
    });

    @Override
    public void onSuccess(BaseBean baseBean) {

    }
}